<?php
/**
 * User: syou
 * Date: 2017/3/20
 */
namespace app\common\validate;
use think\Request;
use think\Log;
class ApiAuth{
    public $request;
    //检测是否是受信用户
    const TOKEN = 'uNtLO8-18nduB9Vt';
    /**
     * 构造函数
     */
    public function __construct(){
        $this->request = Request::instance()->header();
        if( !isset($this->request['time']) || !isset($this->request['sign'])){
            exit(json_encode(array('code'=> 1 ,'msg'=>'Access Denied')));
        }else{
            $str = sha1(self::TOKEN.$this->request['time']);
            if($str != $this->request['sign']){
                exit(json_encode(array('code'=> 1 ,'msg'=>'Access Denied')));
            }
        }
    }
}
?>